/*
	Copyright 2012 J. Gohlke
	Licensed under the Apache License, Version 2.0 (the
	"License"); you may not use this file except in
	compliance with the License. You may obtain a copy
	of the License at

	http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in
	writing, software distributed under the License is
	distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
	OR CONDITIONS OF ANY KIND, either express or
	implied. See the License for the specific language
	governing permissions and limitations under the
	License
 */
package com.gohlke.lwo.textures;

/**
 *
 * @author David Wise
 * 
 * In the following list of projections, 
 * image coordinates are called r (horizontal) and s (vertical).
 */
public enum ProjectionType {
    /*
     * image is projected on a plane along the major axis 
     * (specified in the AXIS subchunk). r and s map to the other two axes.
     */
    Planar (0),
    /*
     * The image is wrapped cylindrically around the major axis. 
     * r maps to longitude (angle around the major axis).
     */
    Cylindrical (1),
    /*
     * The image is wrapped spherically around the major axis.
     * r and s map to longitude and latitude.
     */
    Spherical (2),
    /*
     * Like Planar, but projected along all three axes. 
     * The dominant axis of the geometric normal selects the projection 
     * axis for a given surface spot.
     */
    Cubic (3),
    /*
     * The image is projected on the current camera's viewplane. 
     * r and s map to points on the viewplane.
     */
    Front (4),
    /*
     * r and s map to points (u, v) defined for the geometry 
     * using a vertex map (identified in the BLOK's VMAP subchunk).
     */
    UV (5);
    
    private final int index;
    
    ProjectionType(int index) { this.index = index; }
    
    public int index() { return this.index; }
    
    public static ProjectionType from(int index) {
        for (ProjectionType g : ProjectionType.values())
            if (g.index == index)
                return g;
        return null;
    }
    
}
